package com.android.jump.jumper;

import com.android.jump.Animation;
import android.graphics.Canvas;



public class Jumper extends DrawableObject
{
	private Animation manimationLeft = null;
	private Animation manimationRight = null;
	private Animation mflyanimationLeft = null;
	private Animation mflyanimationRight = null;
	private Animation mCur = null;
	private boolean mFlying = false;
	private boolean mFacingLeft = false;
    @Override
    public void doDraw(Canvas canvas)
    {
    	canvas.drawBitmap(mCur.getCurBitmap(), (float)getPositionX(), (float)getPositionY(), null);
    }

    public Jumper(Animation aniL,Animation aniR, Animation flyL,Animation flyR) {
        super(null);
        // should not be here
        // but to be simple
        mflyanimationLeft = flyL;
        mflyanimationRight = flyR;
        manimationLeft = aniL;
        manimationRight = aniR;
        
        mCur = manimationLeft;
        setArea(10, 10, 30);
    }
    
    public void setFlyani(int side)
    {
        mFlying = true;
    	if(side==1)
    	    mCur = mflyanimationLeft;
    	else
    		mCur = mflyanimationRight;
    } 
    
    public void setNorani(int side)
    {
    	if(side==1)
    	    mCur = manimationLeft;
    	else
    		mCur = manimationRight;
    }
    
    public void startJump() {
        setVelocity(0.0, -120.0);
        setAcceleration(0, 40.0);
    }

    public boolean isFlying() {
        return mFlying;
    }
    
    public void setFacingLeft(boolean b) {
        mFacingLeft = b;
    }
    public boolean isFacingLeft() {
        return mFacingLeft;
    }
    
    public void restore() {
        setPosition(100.0, 340.0);
        setVelocity(0, 0);
        setAcceleration(0.0, 0.0);
        mCur = manimationLeft;
        mFlying = false;
        mFacingLeft = false;
    }
}
